package rpc

import (
	baseLog "gitee.com/zaiqiang231/go-base-app/base_app/log"
	baseRpc "gitee.com/zaiqiang231/go-base-app/base_app/rpc"
	rpcHandler "gitee.com/zaiqiang231/go-base-session/app/rpc/handler"
	"gitee.com/zaiqiang231/go-base-session/app/rpc/proto"
	"google.golang.org/grpc"
)

//经过一下两步 进行proto 生成 go 文件

//protoc --go_out=. *.proto

//protoc --go-grpc_out=. *.proto
//protoc --go-grpc_out=require_unimplemented_servers=false:. *.proto

func InitGRpc(server *baseRpc.GrpcServer) {
	opts := []grpc.ServerOption{}
	grpcServer := grpc.NewServer(opts...)

	sessionServer, err := rpcHandler.GetSessionServer()
	if err != nil {
		baseLog.Fatalf("Failed to get sessionSever instance: %s", err.Error())
	}
	proto.RegisterSessionRpcServiceServer(grpcServer, sessionServer)

	server.Server = grpcServer
}
